package org.pirx.abstraction.byclasses;

import org.pirx.annotations.observer;
import org.pirx.annotations.mutator;

import java.util.Vector;

/**
 * Created by IntelliJ IDEA.
 * User: tonyx
 * Date: Apr 20, 2008
 * Time: 6:07:34 PM
 * To change this template use File | Settings | File Templates.
 */
public class ArrayStack extends AbstractStack {
    protected Vector vector= new Vector();
    protected int limit=-1;
    public synchronized
    @mutator
    void putElement(Object object) {
        vector.insertElementAt(object,limit+1);
        limit++;
    }

    public
    @observer
    Object topElement() {
        if (limit>-1 )
            return vector.elementAt(limit);
        else
            return null;
    }

    public synchronized
    @mutator
    void dropElement() {
        if (limit > -1) {
            vector.removeElementAt(limit);
            limit--;
        }
    }
}
